package br.com.minhasfinancas.api.model;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.validation.constraints.NotNull;

import org.hibernate.annotations.ForeignKey;

import br.com.minhasfinancas.fw.model.AbstractModel;

@Entity
public class Receita extends AbstractModel<Long> {
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy = GenerationType.SEQUENCE)
	@Column(name = "ID_RECEITA")
	private Long id;

	@NotNull
	@Column(name = "VALOR")
	private double valor;

	@NotNull
	@Column(name = "DESCRICAO", length = 45)
	private String descricao;

	@JoinColumn(name = "ID_CONTA")
	@ManyToOne
	@ForeignKey(name = "FK_CONTA_RECEITA")
	private Conta conta;

	@JoinColumn(name = "ID_TIPO")
	@ManyToOne
	@ForeignKey(name = "FK_TIPO_RECEITA")
	private Tipo tipo;

	@ManyToMany
	@JoinTable(name = "RECEITA_DATA", joinColumns = { @JoinColumn(name = "ID_RECEITA") }, inverseJoinColumns = { @JoinColumn(name = "ID_DATA") })
	private List<Data> data;

	@Override
	public Long getId() {
		return this.id;
	}

	@Override
	public void setId(Long id) {
		this.id = id;
	}

	public double getValor() {
		return valor;
	}

	public void setValor(double valor) {
		this.valor = valor;
	}

	public String getDescricao() {
		return descricao;
	}

	public void setDescricao(String descricao) {
		this.descricao = descricao;
	}

	public Conta getConta() {
		return conta;
	}

	public void setConta(Conta conta) {
		this.conta = conta;
	}

	public Tipo getTipo() {
		return tipo;
	}

	public void setTipo(Tipo tipo) {
		this.tipo = tipo;
	}

	public List<Data> getData() {
		return data;
	}

	public void setData(List<Data> data) {
		this.data = data;
	}
	
}
